package com.change.zh.ffmpegdo.push;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.nio.charset.Charset;

public class CommandExec {

    public static String exeCmd(String commandStr) {
        StringBuilder stringBuilder = new StringBuilder();
        try {
            Process process = Runtime.getRuntime().exec(commandStr);
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream(), Charset.forName("GBK")));
            String line = null;
            while ((line = bufferedReader.readLine()) != null) {
                stringBuilder.append(line + "\n");
            }
            int waitFor = process.waitFor();
            bufferedReader.close();
        } catch (Exception e) {
            return "发生异常：" + e.getMessage();
        }
        return stringBuilder.toString();
    }
}
